<template lang="pug">
  .inspect-wrapper
    el-table.table-xxs(
      border
      :data="inspectData"
      height="100%")
      el-table-column(
        v-for="(item, index) of inspectHead"
        :key="index"
        :label="item.label"
        :prop="item.prop")
</template>

<script>

export default {
  name: 'DeviceInspect',
  props: {
    deviceId: {
      type: String | Number
    }
  },
  data () {
    return {
      inspectData: [],
      inspectHead: [
        {
          label: '巡检人',
          prop: 'inspectPerson'
        },
        {
          label: '巡检时间',
          prop: 'inspectTime'
        },
        {
          label: '巡检地址',
          prop: 'inspectAddress'
        },
        {
          label: '巡检结果',
          prop: 'inspectResult'
        }
        // {
        //   label: '创建人',
        //   prop: 'createUserId'
        // },
        // {
        //   label: '创建时间',
        //   prop: 'createTime'
        // },
        // {
        //   label: '修改人',
        //   prop: 'updateUserId'
        // },
        // {
        //   label: '修改时间',
        //   prop: 'updateTime'
        // }
      ]
    }
  },
  mounted () {
    this.getInspectData()
  },
  methods: {
    getInspectData () {
      this.$get({
        url: 'pn/base/deviceInspect',
        params: {
          filterBy: 'deviceId|eq|' + this.deviceId
        }
      }).then(({data}) => {
        this.inspectData = data.map(item => {
          return {
            ...item,
            inspectTime: item.inspectTime ? this.$moment(item.inspectTime).format('YYYY-MM-DD HH:mm') : '-'
            // createTime: this.$moment(item.createTime).format('YYYY-MM-DD HH:mm:ss'),
            // updateTime: this.$moment(item.updateTime).format('YYYY-MM-DD HH:mm:ss')
          }
        })
      })
    }
  }
}
</script>

<style lang="sass" scoped>
.inspect-wrapper
  flex: 1
  /deep/ .el-table
    th, td
      height: 36px
      line-height: 36px
      padding: 0
      text-align: center
      color: #555555
      font-size: 12px
    th
      background: #e8ecef
      font-size: 12px
    tr
      &:nth-child(2n)
        background-color: #f7f8fa
      &:hover
        background-color: #eaeff3
</style>
